<template>
  <div id="emaillogin">
   <div class="images"><img src="../assets/emailbk.png" alt=""></div>
   <form action="" class="phone-form">
     <label for="" class="flex_start">
       <img src="../assets/email.png" alt="">
       <div class="phone-num">
         <input type="email" placeholder="请输入邮箱号" class="inemail" @keyup.13="login()">
       </div>
     </label>
     <label for="" class="flex_start">
       <img src="../assets/pwd.png" alt="">
       <div class="phone-num">
         <input type="password" placeholder="请输入密码" class="empwd" @keyup.13="login()">
       </div>
     </label>
   </form>
   <button @click="login()">登录</button>
  </div>
</template>

<script>
export default {
  name: 'emaillogin',
  data () {
    return {
     
    }
  },
  methods: {
    login() {
      this.axios({
        method: "get",
        url: "https://music.hzbiz.net/login",
        params: {
          email: document.getElementsByClassName("inemail")[0].value,
          password: document.getElementsByClassName("empwd")[0].value,
        },
      }).then((res) => {
        if(res.data.message){
          alert(res.data.message)
        }
        console.log(res.data);
        localStorage.name = res.data.profile.nickname
        this.axios({
          method: "get",
          url: "https://music.hzbiz.net/user/detail",
          params: {
            uid: res.data.profile.userId,
          },
        }).then((res) => {
          this.personData = res.data;
         
          localStorage.userData = JSON.stringify(res.data)
          if (res.data) {
            this.$router.push("/userDetail");
          }
          
        });
      });
    },
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
@import url("../css/login.css");
</style>
